package string;

import java.security.spec.RSAOtherPrimeInfo;
import java.util.Locale;
import java.util.Scanner;

public class Homework28 {
    public static void main(String[] args) {

//1. 生成一个4位验证码(数字和字母的组合)，输出到控制台并提示用户输入验证码，
//   输入后若正确则提示验证码正确，若错误则提示验证码错误。
//   注意：不区分大小写
        String ww="";
        int a;
        String rom="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRETUVWXYZ";

         for(int i=0;i<4;i++) {
             a=(int)(Math.random()*rom.length());
             ww+=rom.charAt(a);
         }
        System.out.println(ww);
        System.out.println("请输入验证码：");

        Scanner scan=new Scanner(System.in);
        String ww1=scan.nextLine();



        if(ww.equals(ww1)){
            System.out.println("输入正确！");
        }else {
            System.out.println("输入错误！");
        }



        String sum="   Hi,My baby,you so beautiful  ";
        System.out.println(sum.length());
        String sum1=sum.trim();
        System.out.println(sum1);
        String num2=sum1.toUpperCase();
        String num3=sum1.toLowerCase();
        System.out.println(num2+"\n"+num3);

        boolean num4=sum1.startsWith("h");
        boolean num5=sum1.endsWith("l");
        System.out.println(num4+","+num5);
        char num6=sum1.charAt(2);
        System.out.println(num6);
        int  num7=sum1.indexOf("y");
        int num8=sum1.lastIndexOf("y");
        System.out.println(num7+","+num8);
        String num9=sum1.substring(3,10);
        System.out.println(num9);

        String are="我是一个好人，请善待我，谢谢";
        StringBuilder is=new StringBuilder(are);
        is.append(",我来自美丽的拉萨！");
        System.out.println(is);
        is.insert(2,"特别好的一个");
        System.out.println(is);
        is.delete(13,18);
        System.out.println(is);
        is.replace(0,1,"你");
        System.out.println(is);

       /*
        String str="     Hello World    ";

        System.out.println(str.length());
        String str1=str.trim();
        System.out.println(str1);
        String str2=str1.toUpperCase();
        String str3=str1.toLowerCase();
        System.out.println(str2+","+str3);
        boolean aoo=str1.startsWith("o");
        boolean boo=str1.endsWith("d");
        System.out.println(aoo+","+boo);
        char str4=str1.charAt(4);
        System.out.println(str4);
        int str5=str1.indexOf("o",3);
        int str6=str1.lastIndexOf("l");
        System.out.println(str5+","+str6);
        String str7=str1.substring(2,5);
        System.out.println(str7);
        int number=1433223;
        String str8=String.valueOf(number);
        System.out.println(str8);

        String as="大家好，我来学习Java";
        StringBuilder builder=new StringBuilder(as);
        builder.append(";全部太卷了，抓紧学习");
        System.out.println(builder);
        builder.delete(8,12);
        System.out.println(builder);
        builder.replace(6,9,"睡一觉");
        System.out.println(builder);
        builder.insert(1,"全体目光向我看齐！");
        System.out.println(builder);

        */



    }
}
